<template>
  <div>
    <div class="search-bar">
      <van-row>
        <van-col span="3">
          <img src="@/assets/weizhi.png" alt="" class="img">
        </van-col>
        <van-col span="16">
          <input type="text" class="search-input">
        </van-col>
        <van-col span="5">
          <!-- <van-button>qwer</van-button> -->
          <van-button size="small" class="btn">查找</van-button>
        </van-col>
      </van-row>
    </div>
    <!-- swiper area -->
    <div class="swiper-area">
      <van-swipe :autoplay="1000">
        <!-- v-for遍历图片引用路径时图片路径前加require('xxxx') -->
        <van-swipe-item v-for="(item ,index) in bannerPicArray" :key="index">
          <img v-lazy="item.image" alt="" width="100%" />
        </van-swipe-item>

        <!-- <van-swipe-item>
          <img src="../../assets/img/1.jpg" alt="" width="100%" />
        </van-swipe-item>
        <van-swipe-item>
          <img src="../../assets/img/2.png" alt="" width="100%" />
        </van-swipe-item>
        <van-swipe-item>
          <img src="../../assets/img/3.jpg" alt="" width="100%" />
        </van-swipe-item> -->

      </van-swipe>
    </div>

    <!-- type bar  -->
    <div class="type-bar">
      <div v-for="(item,index) in category" :key="index">
        <img v-lazy="item.image" width="90%" alt="">
        <span>{{item.mallCategoryName}}</span>
      </div>
    </div>

    <div class="gg">
      <img v-lazy="adBanner" alt="" width="100%">
    </div>


    <div class="recommend">
      <div class="recommend-title">商品推荐</div>
      <div class="recommend-body">
        <swiper :options="swiperOption">
          <swiper-slide v-for="(item,index) in recommendGoods" :key="index">
            <div class="recomend-item">
              <img :src="item.image" width="80%" alt="">
              <div>{{item.goodsName}}</div>
              <div>￥{{item.price | toMoney}}({{item.mallPrice | toMoney}})</div>
            </div>
          </swiper-slide>
        </swiper>
      </div>
    </div>
    <!-- <swiperText/> -->

    <!-- <floor :floorData="floor1" :floorTitle="floorName.floor1" />
    <floor :floorData="floor2" :floorTitle="floorName.floor2" />
    <floor :floorData="floor3" :floorTitle="floorName.floor3" /> -->

    <!--Hot Area-->
    <div class="hot-area">
      <div class="hot-title">热卖商品</div>
      <div class="hot-goods">
        <!--这里需要一个list组件-->
        <van-list>
          <van-row gutter='20'>
            <van-col span="12" v-for="(item,index) in hotGoods" :key="index">
              <goods-info :goodsImage="item.image" :goodsId="item.goodsId"
              :goodsName="item.name" :goodsPrice="item.price"></goods-info>
              <!-- <div>{{item.name}}</div> -->
            </van-col>
          </van-row>
        </van-list>
      </div>
    </div>

  </div>
</template>

<script>
import axios from 'axios'
import 'swiper/dist/css/swiper.css'
import {swiper,swiperSlide} from 'vue-awesome-swiper'
import swiperText from '../swiper/swiperText.vue'
import floor from '../component/floor.vue'
import {toMoney} from '@/filter/moneyFilter.js'
import goodsInfo from '../component/goodInfo.vue'
import url from '@/serviceAPI.config.js'
  export default {
    data() {
      return {
        swiperOption:{
          slidesPerView:3
        },
        msg: 'Shopping Mall' ,
        bannerPicArray:[
                // require('../../assets/img/1.jpg'),
                // require('../../assets/img/2.png'),
                // require('../../assets/img/3.jpg')
        ],
        category:[],
        adBanner:'',
        recommendGoods:'',
        floor1:[],
        floor2:[],
        floor3:[],
        floorName:{},
        hotGoods:[],
      }
    },
    filters:{
      toMoney
    },
    components:{swiper,swiperSlide,floor,goodsInfo},
    created(){
      axios({
        url:url.getShopingMallInfo,
        method:'get',
      })
      .then((Response)=>{
        console.log(Response.data.data)
        if(Response.status==200){
          this.category = Response.data.data.category
          this.adBanner = Response.data.data.advertesPicture.PICTURE_ADDRESS
          this.bannerPicArray = Response.data.data.slides
          this.recommendGoods = Response.data.data.recommend
          this.floor1 = Response.data.data.floor1
          this.floor2 = Response.data.data.floor2
          this.floor3 = Response.data.data.floor3
          this.floorName = Response.data.data.floorName
          this.hotGoods = Response.data.data.hotGoods
        }
      })
      .catch(err=>{
        console.log(err)
      })
    }
  }
</script>

<style scoped>
  .search-bar{
    background: #e5017d;
    height: 2.2rem;
    line-height: 2.2rem;
    overflow: hidden;
  }
  .img{
    width: 80%;
    padding-left: .3rem;
    padding-top: .2rem;
  }
  .search-input{
    width: 100%;
    height: 1.3rem; 
    border: 0;
    border-bottom: 1px solid white;
    background: #e5017d;
    color: white;
  }
  .swiper-area{
    clear: both;
    max-height: 12rem;
    overflow: hidden;
  }
  .type-bar{
    background: white;
    margin:0 .3rem .3rem .3rem;
    border-radius: .3rem;
    font-size: 14px;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
  }
  .type-bar div{
    padding: .3rem;
    font-size: 12px;
    text-align: center;
    flex: 1;
  }
  .recommend{
    background: #fff;
    margin-top: .3rem;
  }
  .recommend-title{
    border-bottom: 1px solid #eee;
    font-size: 14px;
    text-align: center;
    color: violet;
    padding: .2rem;
  }
  .recommend-body{
    border-bottom: 1px solid #eee;
  }
  .recomend-item{
    width: 99%;
    border-right: 1px solid #eee;
    font-size: 12px;
  }
  .hot-area{
      text-align: center;
      font-size:14px;
      height: 1.8rem;
      line-height:1.8rem;
  }
  .hot-goods{
    height: 130rem;
    overflow: hidden;
  }
</style>